package com.sen.patterns.creational.prototype;

public class TestComplex2 {
	Complex2 c1 = new Complex2();

	Complex2 makeCopy() {
		return c1.clone();
	}

	public static void main(String[] args) {
		TestComplex2 tp = new TestComplex2();
		Complex2 c2 = tp.makeCopy();
		int[] mycopy = c2.getNums();
		mycopy[0] = 5;

		System.out.println();
		System.out.print("local array: ");
		for (int i = 0; i < mycopy.length; i++)
			System.out.print(mycopy[i]);
		System.out.println();

		System.out.print("cloned object: ");
		for (int ii = 0; ii < c2.nums.length; ii++)
			System.out.print(c2.nums[ii]);
		System.out.println();

		// 克隆出来对象属性的值改了，原始的对象没有改
		System.out.print("original object: ");
		for (int iii = 0; iii < tp.c1.nums.length; iii++)
			System.out.print(tp.c1.nums[iii]);
	}
}
